package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.CheckGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * @author lcz
 * @date 2020/3/29.
 * @Description  检查组
 */
@RestController
@RequestMapping("checkgroup")
@Slf4j
public class CheckGroupController {
    //依赖注入
    @Reference
    private CheckGroupService checkGroupService;


    //分页查询
    //调 service
    //查询成功 返回成功信息和数据
    //失败  返回失败信息和数据
    @RequestMapping("findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        try {
            //调用service中的分页查询方法
            PageResult pageResult = checkGroupService.pageQuery(queryPageBean);
            //查询成功, 返回查询成功的信息 及 数据
            return pageResult;
        } catch (Exception e) {
            e.printStackTrace();
            //查询失败, 返回查询失败的信息 及 数据
            return new PageResult(0L, null);
        }
    }
}






